
'''
https://leetcode.cn/problems/happy-number/description/

快乐数
'''

def happy(n) -> int:
    if n<10:return n
    res = 0
    for i in str(n):
        res += int(i) ** 2
    return happy(res)
def l202(n) -> bool:

    return happy(n) == 1



if __name__ == '__main__':
    print(l202(19))
    print(l202(2))
    pass